import http from '@/utils/http'

const BASE_URL = '/cakerun/brandAccount'

export interface BrandAccountResp {
  id: string
  brand: string
  area: string
  account: string
  password: string
  init: string
  orderShopTime: string
  orderProjectTime: string
  orderDetailTime: string
  feedbackInfoTime: string
  storeMetricsTime: string
  createTime: string
  updateTime: string
  enable: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface BrandAccountDetailResp {
  id: string
  brand: string
  area: string
  account: string
  password: string
  init: string
  bsid: string
  orderShopTime: string
  orderProjectTime: string
  orderDetailTime: string
  feedbackInfoTime: string
  storeMetricsTime: string
  createTime: string
  updateTime: string
  enable: string
  delFlag: string
  createUserString: string
  updateUserString: string
  deptName: string
  nickname: string
}
export interface BrandAccountQuery {
  brand?: string
  account?: string
  area?: string
  sort?: Array<string>
  enable?: boolean
}
export interface BrandAccountPageQuery extends BrandAccountQuery, PageQuery {}

/** @desc 查询美团账号列表 */
export function listBrandAccount(query: BrandAccountPageQuery) {
  return http.get<PageRes<BrandAccountResp[]>>(BASE_URL, query)
}

/** @desc 查询所有品牌信息列表 */
export function listAllBrand(query: Partial<BrandAccountPageQuery>) {
  return http.get<BrandAccountResp[]>(`${BASE_URL}/list`, query)
}

/** @desc 查询美团账号详情 */
export function getBrandAccount(id: string) {
  return http.get<BrandAccountDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增美团账号 */
export function addBrandAccount(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改美团账号 */
export function updateBrandAccount(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除美团账号 */
export function deleteBrandAccount(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出美团账号 */
export function exportBrandAccount(query: BrandAccountQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
